
{{template "base.html" .}}

{{define "content"}}

<!--操作按钮模板-->

<form class="layui-form" action="" id="Sfrom" style="padding: 10% 20%">
  <div class="layui-form-item">
    <label class="layui-form-label">学号</label>
    <div class="layui-input-block">
      <input type="text" name="Number" required  lay-verify="required" placeholder="请输入学号" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">姓名</label>
    <div class="layui-input-block">
      <input type="text" name="Name" required  lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">年龄</label>
    <div class="layui-input-block">
      <input type="text" name="Age" required  lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">专业</label>
    <div class="layui-input-block">
      <select id="Major_id" lay-verify="required" lay-filter="Major_id" name="Major_id">
        <option value="">请选择</option>

      </select>
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">班级</label>
    <div class="layui-input-block">
      <select id="Class_id" name="Class_id" lay-verify="required" lay-filter="Class_id">
        <option value="">请选择</option>
      </select>
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">单选框</label>
    <div class="layui-input-block">
      <input type="radio" name="Sex" value="男" title="男">
      <input type="radio" name="Sex" value="女" title="女" checked>
    </div>
  </div>

  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="articlesub">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>
<script>

  layui.use('form', function(){
    var form = layui.form;
    //提交
    QueryMajorId();

    form.on('select(Major_id)', function(data){
      QueryClassId(data.value);
      console.log()
    })

    form.on('submit(articlesub)', function(data){
      $.ajax({
        url:'/teacher/stu_add',
        method:'post',
        data:data.field,
        dataType:'JSON',
        success:function(res){
          if(res.code=='0'){
            layer.msg("提交成功",{icon: 1, time: 1000},function(){
              window.location.replace("/teacher");
            }); //提交成功后刷新页面
          }
          else
            window.location.replace("/404?msg="+res.msg);
        },
        error:function (data) {
          window.location.replace("/404?msg="+data);
        }
      });
      return false;
    });
  });


</script>
{{end}}
